"use strict";
var loading = !1
  , app = new Vue({
    el: "#app",
    data: {
        userId: 0,
        cityId: 1,
        tabs: [{
            name: "全部时间",
            id: 0
        }, {
            name: "最近一月",
            id: 1
        }],
        num2: 0,
        listTab: [],
        Type: 0,
        hideing: !0,
        pageIndex: 1,
        pageSize: 10
    },
    created: function() {
        if ("" != $.getPara("userId")) {
            var e = $.getPara("userId");
            this.userId = e,
            $.setStorage("userId", e)
        } else if ($.getStorage("userId") && "" != $.getStorage("userId")) {
            e = parseInt($.getStorage("userId"));
            this.userId = e
        }
        "" != $.getPara().cityId && (this.cityId = $.getPara("cityId")),
        this.getList()
    },
    mounted: function() {
        var t = this;
        this.$nextTick(function() {
            $(document.body).infinite().on("infinite", function() {
                loading || (loading = !0,
                t.hideing = !1,
                setTimeout(function() {
                    var e = t.pageIndex;
                    e++,
                    t.pageIndex = e,
                    t.getList(),
                    loading = !1
                }, 1500))
            })
        })
    },
    methods: {
        getList: function() {
            var a = this;
            $.ajax({
                url: "/api/second/substationList",
                type: "get",
                dataType: "json",
                data: {
                    cityId: a.cityId,
                    timeType: a.Type,
                    pageIndex: a.pageIndex,
                    pageSize: a.pageSize
                }
            }).done(function(e) {
                if (200 == e.code) {
                    var t = e.data.list;
                    if (0 < t.length) {
                        var i = a.listTab.concat(t);
                        a.listTab = i
                    } else
                        loading = !0,
                        $.toast("暂无数据", "text");
                    a.hideing = !0
                }
            })
        },
        tab2: function(e) {
            e != this.Type && (this.Type = e,
            this.pageIndex = 1,
            this.listTab = [],
            this.getList())
        },
        urlHref: function(e) {
            var t = {
                title: "二手详情",
                type: "dynamic"
            };
            t.url = "/PageClassify/html/Substation/secondhand/secondhandDetails.html?id=" + e.id + "&cityId="+this.cityId,
            0 < this.userId && (t.url = "/PageClassify/html/Substation/secondhand/secondhandDetails.html?id=" + e.id + "&userId=" + this.userId +"&cityId=" +this.cityId),
            /(Android)/i.test(navigator.userAgent) ? jsAndroid.appPush(JSON.stringify(t)) : /(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent) ? window.webkit.messageHandlers.appPush.postMessage(t) : window.location.href = t.url
        }
    }
});
